import {GameManager} from "db://assets/scripts/game/GameManager";
import {PlayerDataManager} from "db://assets/scripts/common/PlayerDataManager";
import {EventManager} from "db://assets/scripts/common/EventManager";
import {EventType} from "db://assets/scripts/common/EventType";

/**
 * 添加金币代理
 */
export class GameGoldProxy {
    /**
     * 代理对象
     */
    private proxy: GameManager;

    constructor(proxy: GameManager) {
        this.proxy = proxy;
    }

    /**
     * 添加金币
     *
     * @param value 金币数量
     */
    public addGold(value: number = 1) {
        // 添加金币
        PlayerDataManager.getInstance().getPlayer().gold = Math.ceil(value);
        // 刷新金币事件
        EventManager.dispatchEvent(EventType.REFRESH_GOLD);
    }
}